﻿using System;
using sdamarketing.App_Code;

namespace sdamarketing.Account
{
    public partial class LogOut : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

          if (!IsPostBack)
          {
            try
            {
                    if (Session["iduser"] == null || Session["username"] == null)
                    {
                        Response.Redirect("~/Default.aspx");
                    }
                    if (Session["MyCulture"].ToString() == "en-US")
                    {
                        lblMessage.Text = "You are logged in as " + Session["username"].ToString() + " log out ";                     
                    }
                    else
                    {
                        lblMessage.Text = "Логирани сте како " + Session["username"].ToString() + " одлогирај се ";                     
                    }
                    
            }
            catch (Exception exception)
            {
                SendToLogFile.SendRecordToFIle(DateTime.Now.ToString() + " -exc- " + exception.Message.ToString() + " -stackTrace- " + exception.StackTrace.ToString() + " -LogOut- ");
            }
          }
      }

        protected void btnLogOut_Click(object sender, EventArgs e)
        {
            // AN na logOUt gi trgam od sesijata promenlivite za korisnikot    
            Session.Abandon();
     /*
            Session.Remove("idUser");
            Session.Remove("username");
            Session.Remove("idRole");
      */ 
            Response.Redirect("~/Default.aspx");             
        }
    }
}
